package com.medusa.aps.business.modules.security.model.output;

import cn.hutool.core.annotation.Alias;
import com.baomidou.mybatisplus.annotation.TableField;
import com.medusa.aps.business.model.enums.SourceEnum;
import com.medusa.aps.business.modules.security.mp.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.List;

@Getter
@Setter
@Accessors(chain = true)
public class UserVO {


    /**
     * 主键ID  groups:标识在更新的时候才能验证非空
     */
    @Schema(description = "用户id")
    @Alias("主键id")
    private Long id;
    /**
     * 成员姓名
     */
    @Schema(description = "成员姓名")
    @Alias("成员姓名")
    private String username;


    /**
     * 成员工号
     */
    @Schema(description = "成员工号")
    @Alias("成员工号")
    private String jobNumber;

    /**
     * 职位
     */
    @TableField("position")
    @Schema(description = "职位")
    @Alias("职位")
    private String position;

    /**
     * 车间id
     */
    @Schema(description = "车间id")
    private Integer workshopId;

    /**
     * 车间
     */
    @Schema(description = "车间")
    @Alias("车间")
    private String workshopName;

    /**
     * 密文密码
     */
    @TableField("password")
    @Schema(description = "密文密码")
    private String password;

    /**
     * 密文密码
     */
    @Schema(description = "密文密码")
    private String plainPassword;


    /**
     * 手机号码
     */
    @Schema(description = "手机号")
    @Alias("手机号")
    private String phone;

    /**
     * 邮箱
     */
    @Schema(description = "邮箱")
    @Alias("邮箱")
    private String email;


    /**
     * 数据来源
     */
    @Schema(description = "数据来源")
    private SourceEnum dataSource;

    /**
     * 创建人
     */
    @Schema(description = "创建人")
    private String creator;

    /**
     * 创建时间
     */
    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    /**
     * 备注
     */
    @Schema(description = "备注")
    private String remarks;

    /**
     * 用户角色
     */
    @Schema(description = "用户角色")
    private List<UserRoleVO> userRoles;

    public void setProperties(User user) {
        this.setId(user.getId())
                .setUsername(user.getUsername())
                .setJobNumber(user.getJobNumber())
                .setPosition(user.getPosition())
                .setPhone(user.getPhone())
                .setEmail(user.getEmail())
                .setCreator(user.getCreator())
                .setCreateTime(user.getCreateTime())
                .setRemarks(user.getRemarks());
    }

}